<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of VMT_LoadMap</title>
  <meta name="keywords" content="VMT_LoadMap">
  <meta name="description" content="">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
  <script type="text/javascript">
    if (top.frames.length == 0) { top.location = "../index.html"; };
  </script>
</head>
<body>
<a name="_top"></a>
<!-- menu.html VMT_4.0_dev -->
<h1>VMT_LoadMap
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong></strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function Map = VMT_LoadMap(filetype,coord); </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment">
 This routine loads a map file from either a text file or a .mat file. 

 Input:  filetype = 'txt' for a text file (2 col (x,y), no headers); 'mat' for a matlab data file 
        coord    = 'UTM' for UTM coordinates or 'LL' for latitude, longitude (in dec deg)
        zone     = zone for UTM coordinates (Removed from Input--will be
        determined from the data automatically)</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="VMT.html" class="code" title="function varargout = VMT(varargin)">VMT</a>	--- THE VELOCITY MAPPING TOOLBOX ---</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function Map = VMT_LoadMap(filetype,coord);</a>
0002 <span class="comment">%</span>
0003 <span class="comment">% This routine loads a map file from either a text file or a .mat file.</span>
0004 <span class="comment">%</span>
0005 <span class="comment">% Input:  filetype = 'txt' for a text file (2 col (x,y), no headers); 'mat' for a matlab data file</span>
0006 <span class="comment">%        coord    = 'UTM' for UTM coordinates or 'LL' for latitude, longitude (in dec deg)</span>
0007 <span class="comment">%        zone     = zone for UTM coordinates (Removed from Input--will be</span>
0008 <span class="comment">%        determined from the data automatically)</span>
0009 
0010 
0011 <span class="comment">%P.R. Jackson, 12-9-08</span>
0012 <span class="comment">% Last Modified: Frank L. Engel, 3/13/2013</span>
0013 
0014 <span class="keyword">switch</span> filetype
0015     <span class="keyword">case</span>{<span class="string">'txt'</span>}
0016         defaultpath = <span class="string">'C:\'</span>;
0017         shorepath = [];
0018         <span class="keyword">if</span> 0 <span class="comment">%exist('VMT\LastDir.mat') == 2</span>
0019             load(<span class="string">'VMT\LastDir.mat'</span>);
0020             <span class="keyword">if</span> exist(shorepath) == 7
0021                 [file,shorepath] = uigetfile({<span class="string">'*.txt;*.csv'</span>,<span class="string">'All Text Files'</span>; <span class="string">'*.*'</span>,<span class="string">'All Files'</span>},<span class="string">'Select Map Text File'</span>,shorepath);       
0022             <span class="keyword">else</span>
0023                 [file,shorepath] = uigetfile({<span class="string">'*.txt;*.csv'</span>,<span class="string">'All Text Files'</span>; <span class="string">'*.*'</span>,<span class="string">'All Files'</span>},<span class="string">'Select Map Text File'</span>,defaultpath);
0024             <span class="keyword">end</span>
0025         <span class="keyword">else</span>
0026             [file,shorepath] = uigetfile({<span class="string">'*.txt;*.csv'</span>,<span class="string">'All Text Files'</span>; <span class="string">'*.*'</span>,<span class="string">'All Files'</span>},<span class="string">'Select Map Text File'</span>,defaultpath);
0027         <span class="keyword">end</span>
0028         
0029         <span class="keyword">if</span> ischar(file) <span class="comment">% User did not hit cancel</span>
0030             infile = [shorepath file];
0031             <span class="comment">%disp('Loading Map File...' );</span>
0032             <span class="comment">%disp(infile);</span>
0033             data = dlmread(infile);
0034             <span class="keyword">switch</span> coord
0035                 <span class="keyword">case</span>{<span class="string">'LL'</span>}
0036                     <span class="comment">% convert lat long into UTMe and UTMn</span>
0037                     [Map.UTMe,Map.UTMn,Map.UTMzone] = deg2utm(data(:,1),data(:,2));
0038                 <span class="keyword">case</span>{<span class="string">'UTM'</span>}
0039                     Map.UTMe = data(:,1);
0040                     Map.UTMn = data(:,2);
0041                     <span class="comment">%Map.UTMzone = zone;</span>
0042             <span class="keyword">end</span>
0043         <span class="keyword">else</span>
0044             Map = [];
0045             <span class="keyword">return</span>
0046         <span class="keyword">end</span>
0047                 
0048     <span class="keyword">case</span>{<span class="string">'mat'</span>} <span class="comment">%assumes Map data structure (above) is present</span>
0049         [file,path] = uigetfile(<span class="string">'*.mat'</span>,<span class="string">'Select Map (.mat) File'</span>);
0050         <span class="keyword">if</span> ischar(file) <span class="comment">% User did not hit cancel</span>
0051             infile = [path file];
0052             <span class="comment">%disp('Loading Map File...' );</span>
0053             <span class="comment">%disp(infile);</span>
0054             load(infile);
0055         <span class="keyword">else</span>
0056             Map = [];
0057             <span class="keyword">return</span>
0058         <span class="keyword">end</span>
0059 <span class="keyword">end</span>
0060 
0061 Map.infile = infile;
0062 
0063 <span class="comment">%Save the shorepath</span>
0064 <span class="comment">% if exist('LastDir.mat') == 2</span>
0065     <span class="comment">% save('LastDir.mat','shorepath','-append')</span>
0066 <span class="comment">% else</span>
0067     <span class="comment">% save('LastDir.mat','shorepath')</span>
0068 <span class="comment">% end</span></pre></div>
<hr><address>Generated on Thu 21-Mar-2013 09:32:01 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2005</address>
</body>
</html>